﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U9.AP.Enums;
using UFIDA.U9.CBO.FI.Enums;
using UFIDA.U9.CBO.SCM.Item;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;
using UFSoft.UBF.Util.DataAccess;

namespace UFIDA.U9.CusDev.QJKJPlugInBE
{
    class ProcessForMOInserting : IEventSubscriber
    {
        public void Notify(params object[] args)
        {

            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) return;
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;

            if (key == null || key.GetEntity() == null) return;
            //生产订单
            UFIDA.U9.MO.MO.MO mo = key.GetEntity() as UFIDA.U9.MO.MO.MO;
            if (mo == null) return;

            #region 生产订单三个私有字段(5(备料数),6(领料申请数量),7(领料出库数量)),基于生产订单备料三个字段(备料数量,领料申请数,领料出库数)求和

            //备料数量汇总
            decimal total = 0;
            foreach (var line in mo.MOPickLists)
            {
                total += line.ActualReqQty;
            }
            mo.DescFlexField.PrivateDescSeg5 = total.ToString();

            #endregion

        }

    }
}
